package com.huajiao.management_system.controller;

import com.huajiao.management_system.service.proveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;

import java.util.List;
import java.util.Map;

@Api(tags = "成果相关接口")
@Controller
public class ProveController {
    /**
     * 展示图片
     */
    @Resource
    private proveService proveService;

    @PostMapping("/more")
    @ApiOperation(value = "展示成果图片", notes="通过成果id查看成果")
    @ResponseBody
    public List dispalyImage(Integer resId) {

        return proveService.selectById(resId);
    }

    /**
     * 数据图形化所需数据
     */
    @GetMapping("/charts/{key}")
    @ApiOperation(value = "数据图形化所需数据", notes="数据图形化所需数据")
    @ResponseBody
    public Map<String, Integer> getChartsData(@PathVariable("key") String key){
        if (key.equals("pie")) {
            return proveService.getPie();
        }else {
            return proveService.getLine();
        }
    }
}
